/**
 * 公用请求方法(如果你的api满足下面的规范，则可使用)
 */
import { BaseType } from '@/components/base/form-item/props'
import { DeleteRequestApi, GetRequestApi, PostRequestApi, PutRequestApi } from '@/utils/api/RequestApi'

/**
 * 新增(json数据)
 */
export function commonAdd<T>(url: string, data: BaseType) {
  return new PostRequestApi<T>(url, data).get()
}

/**
 * 修改(json数据)
 */
export function commonUpdate<T>(url: string, data: BaseType) {
  return new PutRequestApi<T>(url, data).get()
}

/**
 * 删除(url传参)
 */
export function commonDeleteByIds(url: string, ids: string) {
  return new DeleteRequestApi<boolean>(url + ids).get()
}

/**
 * 根据id查询(url传参)
 */
export function commonGet<T>(url: string, id: string) {
  return new GetRequestApi<T>(url + id).get()
}

/**
 * 分页查询(json数据)
 */
export function commonPage<T>(url: string, data: BaseType) {
  return new PostRequestApi<T>(url, data).get()
}
